package com.example.elasticsearchboot.clickhouse.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.elasticsearchboot.clickhouse.entity.OntimeEntity;
import com.example.elasticsearchboot.clickhouse.service.IOntimeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description TODO
 * @Author huangbq
 * @Date 2024-04-29
 */
@RestController
@RequestMapping("/ontime")
public class OntimeController {
    @Resource
    private IOntimeService ontimeService;

    @RequestMapping("/query")
    public List<OntimeEntity> queryBy(Integer year){
        LambdaQueryWrapper<OntimeEntity> wrapper = Wrappers.lambdaQuery(OntimeEntity.class)
                        .eq(OntimeEntity::getYear,year)
                .last("limit 2")
                ;
        return ontimeService.list(wrapper);

    }
}
